"""定义当前访问模型类的文件."""
from datetime import datetime
from typing import List, Union

from fastapi import Query
from pydantic import BaseModel, ConfigDict, Field

from api.v1.models.pagination import PagenationRequest, PaginationResponse


class CurrentConnectListRequest(PagenationRequest):
    """当前访问成员列表Lup请求模型"""
    only_member: str = Field(
        Query(default="N",
             title="仅显示访问成员",
             description="Y: 仅显示访问成员, N: 完全显示",
             example="N"))


class CurrentConnectResponse(BaseModel):
    """当前访问成员信息模型"""
    model_config = ConfigDict(from_attributes=True)

    lo_id: int
    lo_ip: str
    mb_id: Union[str, None]
    mb_nick: Union[str, None]
    mb_email: Union[str, None]
    mb_homepage: Union[str, None]
    mb_image: Union[str, None]
    lo_datetime: datetime
    lo_location: str
    lo_url: str


class CurrentConnectListResponse(PaginationResponse):
    """当前访问成员列表Lup响应模型"""
    logins: List[CurrentConnectResponse]
